package com.hqyj.controller;


import com.hqyj.entity.SearchBean;
import com.hqyj.pojo.TbBuilding;
import com.hqyj.service.TbBuildingService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 * 楼栋表 前端控制器
 * </p>
 *
 * @author gp
 * @since 2021-09-25
 */
@RestController
@RequestMapping("/tb-building")
public class TbBuildingController {
    @Autowired
    TbBuildingService buildingService;
    /**
     * 127.0.0.1:8080/tb-building/list ---- get
    * @Description:
    * @Date:2021/9/27 10:11
    */
    @GetMapping("/list")
    public HashMap<String ,Object> list(TbBuilding building){
        return buildingService.List(building);
    }

    /**
     * 127.0.0.1:8080/tb-building/listPage ---- get
     */
    @GetMapping("/listPage")
    public HashMap<String, Object>  listPage(SearchBean searchBean){
        return buildingService.listPage(searchBean);
    }
    /**
     * http://localhost:8080/tb-building/add
    * @Description:
    * @Date:2021/9/27 10:11
    */
    @PostMapping(value = "/add", consumes = "application/json")
    public HashMap<String ,Object> insert(@RequestBody TbBuilding building){
        return buildingService.insert(building);
    }

    /**
     * 127.0.0.1:8080/tb-building/update ---- put
     * @Description:
     * @Date:2021/9/27 10:11
     */
    @PutMapping(value = "/update",consumes = "application/json")
    public HashMap<String ,Object> update(@RequestBody TbBuilding building){
        return buildingService.update(building);
    }
    /**
     * 127.0.0.1:8080/tb-building/del/{id} ---- delete
     * @Description:
     * @Date:2021/9/27 10:11
     */
    @DeleteMapping("/del/{id}")
    public HashMap<String ,Object> delete(@PathVariable Integer id){
        return buildingService.delete(id);
    }
    /**
     * http://localhost:8080/tb-building/list
    * @Description:
    * @Date:2021/9/30 9:04
    */
    @GetMapping("/queryByName")
    public HashMap<String ,Object> queryByName(@PathVariable String name){
        return buildingService.queryByName(name);
    }
}

